<?php

namespace App\Modules\Admin\Http\Controllers;


use App\Http\Controllers\BaseController;
use App\Services\MeetHourService;
use Illuminate\Http\Request;

class MeetHourController extends BaseController
{
    public function __construct(MeetHourService $meetHourService)
    {
        $this->middleware('check.adminLogin')->except('index');

        $this->meetHourService = $meetHourService;
    }

    public function index()
    {
        $param = [];
        $data = $this->meetHourService->getList($param);

        return $this->response->success($data);
    }

    public function show(Request $request)
    {
        $id = $request->input('id');
        $result = $this->meetHourService->getInfo($id);

        return $this->response->success($result);
    }

    public function store(Request $request)
    {
        $param = $this->validationParameter([
            'venue_id|场馆id' => 'require|number',
            'meet_day_id|日期id' => 'require|number',
            'start|开始时间点' => 'require',
            'end|结束时间点' => 'require',
            'is_limit|是否人数限制' => 'noRequire',
            'limit|报名上限' => 'noRequire',
            'status|状态' => 'noRequire|number|default:1',
        ]);

        $param['publisher_uid'] = $request->user()->admin_uid ?? null;

        $result = $this->meetHourService->add($param);

        return $this->response->success($result);
    }

    public function update(Request $request)
    {
        $id = $request->input('id');
        $param = [];
        $result = $this->meetHourService->update($param, $id);

        return $this->response->success($result);
    }

    public function destroy(Request $request)
    {
        $id = $request->input('id');
        $result = $this->meetHourService->delete($id);

        return $this->response->success($result);
    }
}
